# coding=utf-8
'''
目录扫描
'''
import requests,threading,time

class Smmulv(object):
	header = {'User-Agent':'Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.101 Safari/537.36'}

	def __init__(self):
		self.sj = time.strftime("%Y_%m_%d_%H_%M_%S", time.localtime())+'.html'
	def Sm(self,line,dic):

		with open(dic,'r') as fo:
			for li in fo.readlines():
				ur = line+"/"+li.strip('\n').strip('\r')
				pd = requests.head(url=ur,allow_redirects=False,verify=False,headers=self.header)
				de = pd.status_code
				print ur+"   "+str(de)
				if de == 200 or de == 301:
					a = '<a target=_blank href='+ur+'>'+ur+"========>   "+str(de)+'</a><br>'
					print a
					jg_url = open('%s' % self.sj,"wb+")
					jg_url.write(a+'\n')
					jg_url.close()
	def domemv(self,ur):
		pd = requests.head(url=ur,allow_redirects=False,verify=False,headers=self.header)
		de = pd.status_code
		print ur+"   "+str(de)
		if de == 200 or de == 301:
			a = '<a target=_blank href='+ur+'>'+ur+"========>   "+str(de)+'</a><br>'
			print a
			jg_url = open('%s' % self.sj,"wb+")
			jg_url.write(a+'\n')
			jg_url.close()
# wz =Smmulv()
# dic = '../dict/a.txt'
#wz.Sm('http://127.0.0.1',dic)
#wz.domemv(ur='http://127.0.0.1/1.txt')